﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TireBias.Models.BIASPLANModel.BIASPLAN_DS>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    New_Sample
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table width="98%" class="shadow">
        <tr>
            <td colspan="2" style="background-color: #E46C0A; color: White; font-size: xx-large;
                text-align: center;">
                New Sample&nbsp; <span class="fontTh">(ผ้าใบทดลอง)</span>
            </td>
        </tr>
        <tr class="rowb">
            <td class="head cell text-right" style="width: 35%; padding: 10px 0px;">
                Size &nbsp;<span class="fontTh">ขนาดผ้าใบ</span>
            </td>
            <td class="cell">
                <%: Model._Size %>
            </td>
        </tr>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                Forming&nbsp;<span class="fontTh">เครื่องที่สร้าง</span>
            </td>
            <td class="cell">
                <%: Model._Forming %>
            </td>
        </tr>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                Topped Cord &nbsp;<span class="fontTh">ชนิดผ้าใบ</span>
            </td>
            <td class="cell">
                <%: Model._Topcrdcd %>
            </td>
        </tr>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                Tire Cord Lot <span class="fontTh">ล็อตผ้าใบ</span>
            </td>
            <td class="cell">
                <%: Model._tcrdlot %>
            </td>
        </tr>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                Expired date <span class="fontTh">วันหมดอายุ</span>
            </td>
            <td class="cell">
                <%: Model._topexp %>
            </td>
        </tr>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                Length (M.) &nbsp;<span class="fontTh">ความยาว (ม.)</span>
            </td>
            <td class="cell">
                <%: Model._toplen %>
            </td>
        </tr>

    </table>
    <table width="98%" class="shadow">
            <tr class="rowa">
            <td class="head cell text-right" style="padding: 10px 0px;" colspan="2">
                TAG PLAN
            </td>
        </tr>
        <tr class="rowb" style="background-color:#D0D8E8">
            <td class=" cell " style="text-align:center;">
                <input type="button" class="chk" value="P1" /><br />
                <input type="button"  class="chk" value="P2" /><br />
                <input type="button"  class="chk" value="P3" /><br />
                <input type="button" class="chk" value="P4" />
            </td>
            <td class="cell">
                <input type="button" class="chk2 " value="P1" /><br />
                <input type="button" class="chk2 " value="P2" /><br />
                <input type="button" class="chk2 " value="P3" /><br />
                <input type="button" class="chk2 " value="P4" />
            </td>
        </tr>
    </table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="TableContent" runat="server">
    <div style="clear: left; margin-top: 15px; ">
    <% if(Model._Actflag =="")  {%>
      <div class="float-left" style="margin-left: 50px;">
          <input type="button" id="back" value="BACK" class="btnFooter"  
              style="height: 75px;  width: 350px;" />
        
      </div>
      <% } %>
      <div style="float: right; margin-right: 35px;">
        <input id="next" type="button" value="NEXT" class="btnFooter" 
              style="height: 75px; width: 350px;" />
      </div>
   </div>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="ScriptsSection" runat="server">
    <style type="text/css">
  .chk,.chk2
  {
     width:90% !important; 
     height:75px!important;       
     cursor:pointer;      
     background-color:#ffffff!important;
  }
  .act
  {     
     background-color:Orange !important;
     border:none !important;
     color:White;
  }
</style>
<% if (false)
   { %>
<script src="../../Scripts/jquery-1.7.1.js" type="text/javascript"></script>
<% } %>
<script type="text/javascript">
    $(function () {

        $("#back").click(function () {
            var url = '<%= Url.Action("RollBack") %>' + '?seq=' + '<%= Model._Plandt %>' + "-" + '<%=Model._Itemno %>';
            url = url + "&st=1&biasno=" + '<%: Model._Biasno %>' + '&shift=' + '<%: Model._Shift %>'+'&blnNewSample="1"';
            window.location = url;
        });

        $(".chk").click(function () {

            if ($(this).hasClass('act')) {
                $(this).removeClass('act');
            } else {
                $(".chk").removeClass('act');
                $(this).addClass('act');
            }
        });
        $(".chk2").click(function () {

            if ($(this).hasClass('act')) {
                $(this).removeClass('act');
            } else {
                $(".chk2").removeClass('act');
                $(this).addClass('act');
            }
        });

        $("#next").click(function () {
            Savedata()
        });

        function Savedata() {

            if ($(".act").length < 1) {
                return;
            }
            var P1 = null;
            var P2 = null;

            if ($(".act").length > 1) {
                P1 = $(".act:first").val();
                P2 = $(".act:eq(1)").val();
            } else {
                P1 = $(".act:first").val();
            }
            var dataForSubmit = new Array();
            dataForSubmit.push({
                _biasno: '<%: Model._Biasno %>',
                _plandt: '<%: Model._Plandt %>',
                _itemno: '<%: Model._Itemno %>',
                _empname: '<%: User.Identity.Name %>',
                _Ply1: P1,
                _Ply2: P2,
                _shift: '<%: Model._Shift %>'
            });
            var getUsersUrl = '<%= Url.Action("SAVE_SUB_ITEM","BiasHead") %>';

            callScriptMethod(getUsersUrl, { theData: dataForSubmit }, 'ADD');
        }
        function callScriptMethod(url, jsonObject, action, callback, async) {

            callback = callback || function () { };
            async = (async == null || async);

            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: url,
                data: JSON.stringify(jsonObject),
                dataType: "json",
                async: async,
                success: function (data) {

                    if (data.success != "0") {
                        var getUsersUrl = '<%= Url.Action("New_Sample_SUB","NewSample") %>' + '?seq=' + '<%: Model._Plandt %>' + '-' + '<%: Model._Itemno %>';
                        window.location = getUsersUrl;
                    } else alert(data.message);
                },
                error: function (xhr, status, error) {
                    var err = xhr.responseText;
                    alert(err.Message);
                }
            });
        }
    });
</script>
</asp:Content>
